import QS from 'qs'
// 测试登录
// const Loin = 'http://192.168.10.150:9100/nn-system'
export const api = {
	login: '/sys/user/login',
	logout: 'sys/user/logout', //退出登录
	getUserInfo: 'sys/user/info',
	refreshToken: 'sys/user/refresh', //刷新token
	/* uploadFile: 'file/upload', //文件上传返回url
	previewFile: 'file/preview', //图片-视频预览 */
	uploadFile: 'sys/upload', //文件上传返回url

	///wx/uploadSingle
	previewFile: '/sys/preview', //图片-视频预览
	getMd5PassIsNull: '/sys/user/getMd5PassIsNull', //获取用户是否有md5密码
	getQrCode: '/sys/wxQrCode/getQrCode', //获取登录二维码
	getLoginState: '/sys/wxQrCode/getLoginState', //查询登录状态
	sendWx: '/sys/transfer/sendWx', //发送消息到小程序
	delVerify: '/sys/user/delVerify', //校验md5 密码
	setDelVerify: '/sys/user/setDelVerify', //设置删除时候是否需要校验密码
}
export function getapi() {
	return api
}
export const sysManageapi = {
	orgUrl: {
		/* 查询机构 */
		getList: '/sys/org/page',
		/* 查询所有机构 */
		getAllList: '/sys/org/list',
		/* 新增机构 */
		add: '/sys/org/insert',
		/* 编辑机构 */
		edit: '/sys/org/update',
		/* 删除机构 */
		delete: '/sys/org/delete',
		upLoginCache: '/sys/org/upLoginCache'
	},
	/* 角色 */
	roleUrl: {
		/* 获取所有角色 */
		getAllList: '/sys/role/list',
		/* 获取角色 */
		getList: '/sys/role/page',
		add: '/sys/role/insert',
		edit: '/sys/role/update',
		delete: '/sys/role/delete',
		setRoleDept: '/sys/role/setRoleDept',
		setRoleMenu: '/sys/role/setRoleMenu',
		setRoleUser: '/sys/role/setRoleUser',
		roleByMenu: '/sys/role/roleByMenu',
		roleByDept: '/sys/role/roleByDept',
		getBindUser: '/sys/role/bind', //获取角色关联账户
		cleRoleUser: '/sys/role/cleRoleUser'
	},
	/** 数据字典 **/
	dictUrl: {
		getList: '/sys/dict/page',
		add: '/sys/dict/insert',
		edit: '/sys/dict/update',
		delete: '/sys/dict/delete',
		/* 字典详情 */
		getItemList: '/sys/dict/item/page',
		/* 新增字典数据项 */
		addItem: '/sys/dict/item/insert',
		/* 编辑字典数据项 */
		editItem: '/sys/dict/item/update',
		/* 删除字典数据项 */
		deleteItem: '/sys/dict/item/delete',
		/*获取字典项下拉*/
		getDictItemKeyList: '/sys/dict/getDictByItem'
	},
	deptUrl: {
		getList: '/sys/dept/list',
		//getDeptlist:  '/sys/dept/page',
		getDeptList: '/sys/dept/listByAuth',
		add: '/sys/dept/insert',
		edit: '/sys/dept/update',
		delete: '/sys/dept/delete',
		getRegion: '/sys/xzqh/list',
	},
	menuUrl: {
		getList: '/sys/menu/list',
		add: '/sys/menu/insert',
		edit: '/sys/menu/update',
		delete: '/sys/menu/delete',
	},
	userUrl: {
		getList: '/sys/user/page',
		/* 新增用户 */
		add: '/sys/user/insert',
		/* 修改用户信息 */
		edit: '/sys/user/update',
		delete: '/sys/user/delete',
		setUserRole: '/sys/user/setUserRole',
		/* 修改用户密码 */
		changePwd: '/sys/user/updatePass',
		/* 重置密码 */
		resetPwd: '/sys/user/resetPass',
		/* 新——修改用户信息 */
		updateInfo: '/sys/user/updateInfo',
		/* 设置用户机构 */
		setUserOrg: '/sys/user/setUserOrg'

	},

	minimenuUrl: {
		getList: '/sys/menuWc/list',
		add: '/sys/menuWc/insert',
		edit: '/sys/menuWc/update',
		delete: '/sys/menuWc/delete',

	},



}
export const deviceManageapi = {
	prodTypeUrl: {
		getList: '/sys/prodType/selectBy',
		add: '/sys/prodType/insert',
		edit: '/sys/prodType/update',
		delete: '/sys/prodType/delete',
	},
	deviceTypeUrl: {
		getList: '/sys/deviceType/selectBy',
		add: '/sys/deviceType/insert',
		edit: '/sys/deviceType/update',
		delete: '/sys/deviceType/delete',

	},
	deviceUrl: {
		getList: '/sys/sysDevice/page',
		add: '/sys/sysDevice/insert',
		edit: '/sys/sysDevice/update',
		delete: '/sys/sysDevice/delete',
	}
}
export const accountManageapi = {
	accountUrl: {
		getList: '/sys/userDetail/findPage',
		add: '/sys/prodType/insert',
		edit: '/sys/prodType/update',
		delete: '/sys/prodType/delete',
	},

}
export const doctorManageapi = {
	doctorUrl: {
		getList: '/sys/docterNurses/findPage',
		add: '/sys/docterNurses/insert',
		edit: '/sys/docterNurses/update',
		delete: '/sys/docterNurses/delete',
		allotPatients: '/sys/docterNurses/allotPatients', //给医生护士分配病人
		findAllotPatients: '/sys/userDetail/findAllotPatients', //查询分配给指定医生护士的的病人
		findNoAllotPatients: '/sys/userDetail/findNoAllotPatients', //查询未分配给指定医生护士的的病人
		upload: '/sys/docterNurses/upload',
		getdocBP2AList: '/sys/docBP2A/sfPage', //随访(血压)-医生分页--历史查询
		gedocBoList: '/sys/docBo/sfPage' //随访(血糖)-医生分页--历史查询
	},
	scheduleUrl: {
		add: '/sys/HospSchedule/insert',
		edit: '/sys/HospSchedule/update',
		getList: '/sys/HospSchedule/getCalendar',
		delete: '/sys/HospSchedule/delete'
	}

}
export const patientManageapi = {
	patientUrl: {
		getList: '/sys/patient/findPage',
		upload: '/sys/patient/upload',
		add: '/sys/patient/insert',
		edit: '/sys/patient/update',
		delete: '/sys/patient/delete',
	}
}

import {
	axios
} from '@/utils/request'

export function postAction(url, params, obj = {}) {
	return axios(Object.assign({}, {
		url: url,
		method: 'post',
		headers: {
			'Content-Type': 'application/json;charset=UTF-8'
		},
		data: params
	}, obj))
}
/** 
 * post方法，对应post请求 
 * @param {String} url [请求的url地址] 
 * @param {Object} params [请求时携带的参数] 
 */
export const getAction = (url, params, obj) => {
	return axios(Object.assign({}, {
		url: url,
		method: 'get',
		params: params
	}, obj))
}
export function getDict(type) {
	return postAction(api.getDict, {
		dictType: type
	})
}
export function logout() {
	return postAction(api.logout)
}

export function upLoginCache(orgId) {
	return postAction(sysManageapi.orgUrl.upLoginCache + '?orgId=' + orgId)
}
export function postActionUpload(url, parameter) {
	return axios({
		url: url,
		method: 'post',
		headers: {
			"Content-Type": "multipart/form-data"
		},
		processData: false,
		data: parameter
	})
}
export function postActionExport(url, parameter) {
	return axios({
		url: url,
		method: 'post',
		headers: {
			"Content-Type": "multipart/form-data;charset=UTF-8"
		},
		responseType: 'blob',
		data: parameter
	})
}

export function getMenubyUser() {
	return postAction(sysManageapi.menuUrl.getList)
}
export function setToken(refreshToken) {
	return postAction(api.refreshToken, refreshToken)
}